<template>
  <img alt="Vue logo" src="./assets/logo.png">
  <!-- <HelloWorld msg="Welcome to Your Vue.js App"/> -->
  <MarkDown></MarkDown>
  <div>
    <button @click="goToRobot">About</button><br>
    <button @click="goToCanvoInfo">About</button>
    <h2>Select</h2>
    <select class="dropdown" v-model="selected" v-if="names">
      <option v-for="name in names" :key="name">{{ name }}</option>
    </select>
    <span>Selected: {{ selected }}</span>
  </div>
</template>

<script>
import MarkDown from './components/MarkdownEditor.vue'
import axios from 'axios'

export default {
  name: 'App',
  data() {
    return {
      names: [] // 添加 names 属性并初始化为空数组
    }
  },
  components: {
    MarkDown
  },
  methods: {
    goToRobot()  {
      axios.get('http://127.0.0.1:8087/robot/getAllRobotNames')
        .then(response => {
          console.log(response.data);
          const valuesArray = Object.values(response.data);  //response.data是一个对象
          console.log(valuesArray[1][0]);
          console.log(valuesArray[1][1]);
          console.log(valuesArray[1][2]);
          console.log(1);
          this.names = response.data;
          // 处理成功响应
        })
        .catch(error => {
          console.error(error);
          // 处理错误响应
        });
    },
    goToCanvoInfo()  {
      axios.get('http://127.0.0.1:8087/roadNetworkDesign/floor/getCanvasInfo?networkName=dsa&floor=1')
        .then(response => {
          console.log(response.data);
          
          // 处理成功响应
        })
        .catch(error => {
          console.error(error);
          // 处理错误响应
        });
    }
  }
}
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
  .dropdown {
    width: 200px;
  }
}
</style>
